<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>技能课程列表</title>
		<link rel="stylesheet" type="text/css" href="../../css/api.css" />
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/aui.css">
		<link rel="stylesheet" href="../../css/base.css" />
		<link rel="stylesheet" href="../../css/personal.css">
		<link rel="stylesheet" href="../../css/CFNetPP_Base.css">
		<link rel="stylesheet" href="../../css/weui.css">
		<link rel="stylesheet" href="../../css/weui.min.css">
		<style>
			.AuthenticationCousre .mui-table-view-cell > a:not(.mui-btn) .course-img {
				display: block;
				width: 136px;
				max-width: 136px;
				height: 84px;
				background-image: url(../../image/course_placehoder.png);
				background-size: 136px 84px;
			}
			.weui_mask {
				position: fixed;
				z-index: 998;
				top: 0;
				right: 0;
				bottom: 0;
				left: 0;
			}
			.weui_dialog {
				z-index: 999;
			}
			.borderLine {
				border-top: 1px solid #DEDEDE;
			}
		</style>
	</head>
	<body>
		<div id="main"  class="borderLine AuthenticationCousre" >
			<ul id="list_id" class="mui-table-view"></ul>
			<div class="noSign"   id="noData"  hidden="hidden">
				<img src="../../image/icon_img.png" width="60%">
				<p class="font16 top_15 base_dark_grey" >
					暂无数据
				</p>
			</div>
			<div class="loadFailure" hidden="hidden" id="noNet">
				<img src="../../image/icon_img01.png" width="60%">
				<p class="" >
					数据加载失败
				</p>
				<p>
					请检查您的网络
				</p>
				<button type="button" class="mui-btn mui-btn-outlined" onclick="RefreshData()">
					重新加载
				</button>
			</div>
		</div>
		<div class="weui_dialog_alert" id="ScoreAlert" style="display: none;">
			<div class="weui_mask"></div>
			<div class="weui_dialog">
				<div class="weui_dialog_hd">
					<strong class="weui_dialog_title">查看成绩</strong>
				</div>
				<div class="weui_dialog_bd">
					<span class=" font14 ">考核:<span class="left_5" id="workname"></span></span>
					<span class=" font14">得分:<span class=" left_5"style="color: red">99</span></span>
				</div>
				<div class="weui_dialog_ft">
					<a onclick="hideScore()" href="#" class="weui_btn_dialog primary" style="color:#18b4ed">确定</a>
				</div>
			</div>
		</div>
		<div class="weui_dialog_confirm" id="TestCodeAlert" style="display: none">
			<div class="weui_mask"></div>
			<div class="weui_dialog">
				<div class="weui_dialog_hd">
					<strong class="weui_dialog_title" id="checkNum">当前处于非wifi条件下,是否继续观看视频</strong>
				</div>
				<div class="weui_dialog_bd"></div>
				<div class="weui_dialog_ft">
					<a onclick="TestCodeNo()" href="#" class="weui_btn_dialog default" style="color:#18b4ed">取消</a>
					<a onclick="TestCodeYes()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script src="../../script/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/getToken.js"></script>
	<script src="../../script/common.js"></script>
	<script type="text/javascript">
		var message;
		var refreshCount = 0;
		//更新数据条数
		var dataArr = new Array();
		var weightratio = new Array();
		var Itemarr = new Array();
		var page = 1;
		var row = 10;
		var chaptername = "";
		var chapterVideourl = "";
		var imgStr = '../../image/course_placehoder.png';
		apiready = function() {
			api.setScreenOrientation({
				orientation : 'portrait_up'
			});
			ReceNotifi();
			showProgress();
			loadNewData();
			setRefreshHeader();
			setPullUpRefresh();
			message = api.pageParam.quarter_name + '技能课程'
		}
		function ReceNotifi() {
			api.addEventListener({
				name : 'RefreshSkilCourseList'
			}, function(ret, err) {
				//coding...
				loadNewData();
			});
		}

		function loadNewData() {
			page = 1;
			loadData();
		}

		function loadMoreData() {
			page++;
			loadData();
		}

		//考试编码正确，点击确定按钮,显示选择考核弹窗
		function TestCodeYes() {
			$('#TestCodeAlert').hide();
			//			toPlayVideo(chapterVideourl, chaptername);
			pushToBaiDuPlayer(0, '', chapterVideourl, chaptername);
		}

		//点击考试编码取消按钮，隐藏考试编码弹窗
		function TestCodeNo() {
			$('#TestCodeAlert').hide();
		}

		function loadData() {
			var param = {
				uid : $api.getStorage('cfnetppuid'),
				jid : 52, //集团id
				page : page,
				rows : row,
				quarter_id : api.pageParam.id,
			};
			cfnetppPOST(url_getSkillsList, param, true, function(data, status) {
				api.refreshHeaderLoadDone();
				hideProgress();
				if (status == 'success') {
					$('#noNet').hide();
					if (data.code == 200) {
						$('#noData').hide();
						var list = data.data.list;
						if (list != null && list.length > 0) {
							refreshCount = list.length;
							var numArr = new Array();
							var examIdArr = new Array();
							for (var k = 0; k < list.length; k++) {
								var lists = list[k].num;
								var learn_test = list[k].learn_test;
								numArr.push(lists);
								examIdArr.push(learn_test);
							}
							if (list[0].where_type == 1) {
								multiplePicturesCache({
									picArr : numArr, //包含图片数组
									picKey : 'coverimages', //图片对应的字段
									isOriginals : 1
								}, function(imageArr) {
									numArr = imageArr;
									htmlStringWithNameTwo(numArr, examIdArr, list[0].learn_test);
								});
							} else {
								multiplePicturesCache({
									picArr : numArr, //包含图片数组
									picKey : 'img', //图片对应的字段
									isOriginals : 1,
								}, function(imageArr) {
									numArr = imageArr;
									htmlStringWithName(numArr, examIdArr, list[0].learn_test);
								});
							}
						} else {
							if (page == 1) {
								$('#noData').show();
							} else {
								api.toast({
									msg : '暂无数据',
									duration : 2000,
									location : 'bottom'
								});
							}
							$('#list_id').html('');
						}
					} else {
						if (page == 1) {
							$('#list_id').html('');
							$('#noData').show();
						}
					}
				} else {
					//					$('#noData').show();
					$('#noNet').show();
				}
			});
		}

		function htmlStringWithName(data, examIdArr, istest) {
			var strhtml = "";
			var btnStr = "";
			var coursenameStr = "";
			var courseinfoStr = "";
			for (var i = 0; i < data.length; i++) {
				var list = data[i];
				data[i].title = list.title;
				imgStr = list.img;
				if (data[i].where_type == 1) {//课程类型为1
					coursenameStr = list.coursename;
					courseinfoStr = list.courseinfo
				} else {
					coursenameStr = list.title;
					courseinfoStr = list.content;
				}
				var DataArr = JSON.stringify(data[i]).replace(/"/g, '&quot;');
				if (examIdArr[i] > 0) {//是否章节练习
					if (list.status == 1) {
						btnStr = '<span class="chapter_btn mui-pull-left" onclick="openTestScore(' + DataArr + ',' + list.cjid + ',' + examIdArr[i] + ')">查看成绩' + '</span>'
					} else {
						btnStr = '<span class="chapter_btn mui-pull-left" onclick="openTest(' + DataArr + ',' + list.eid + ',' + list.enumber + ')">章节练习' + '</span>'
					}
				}
				var str = '<li class="mui-table-view-cell mui-media one_cell"  where_type="' + data[i].where_type + '"  id="' + list.id + '"  coursetype="' + list.coursetype + '" cdetailtitle="' + coursenameStr + '" bewrite="' + courseinfoStr + '" img="' + list.img + '">' + '<a href="javascript:;">' + '<img class="mui-media-object mui-pull-left course-img" src="' + imgStr + '"   onerror="Imgnofind()"/>' + '<div class="mui-media-body top-content">' + '<p class="course_title">' + coursenameStr + '</p>' + '</div>' + '<div class="mui-media-body bottom-content">' + '<div class="">' + '<p class="mui-ellipsis subtitle">' + btnStr + '</p>' + '</div>' + '</div>' + '</a>' + '</li>';
				strhtml = strhtml + str;
			}
//			Itemarr = data;
			if (page == 1) {
				$('#list_id').html(strhtml);
			} else {
				$('#list_id').append(strhtml);
			}
			setupTapCellClick();
		}

		function htmlStringWithNameTwo(data, examIdArr, istest) {
			var strhtml = "";
			var btnStr = '';
			var coursenameStr = "";
			var courseinfoStr = "";
			for (var i = 0; i < data.length; i++) {
				var list = data[i];
				data[i].title = list.title;
				imgStr = list.img;
				if (data[i].where_type == 1) {//课程类型为1
					coursenameStr = list.coursename;
					courseinfoStr = list.courseinfo
				} else {
					coursenameStr = list.title;
					courseinfoStr = list.content;
				}
				var DataArr = JSON.stringify(data[i]).replace(/"/g, '&quot;');
				if (examIdArr[i] > 0) {//是否章节练习
					if (list.status == 1) {
						btnStr = '<span class="chapter_btn mui-pull-left" onclick="openTestScore(' + DataArr + ',' + list.cjid + ',' + examIdArr[i] + ')">查看成绩' + '</span>'
					} else {
						btnStr = '<span class="chapter_btn mui-pull-left" onclick="openTest(' + DataArr + ',' + list.eid + ',' + list.enumber + ')">章节练习' + '</span>'
					}
				}
				var str = '<li class="mui-table-view-cell mui-media one_cell"  where_type="' + data[i].where_type + '"  id="' + list.id + '"   coursetype="' + list.coursetype + '"    cdetailtitle="' + coursenameStr + '"  bewrite="' + courseinfoStr + '"  img="' + list.img + '">' + '<a href="javascript:;">' + '<img class="mui-media-object mui-pull-left course-img" src="' + imgStr + '"   onerror="Imgnofind()"/>' + '<div class="mui-media-body top-content">' + '<p class="course_title">' + coursenameStr + '</p>' + '</div>' + '<div class="mui-media-body bottom-content">' + '<div class="">' + '<p class="mui-ellipsis subtitle">' + btnStr + '</p>' + '</div>'
				// +                      '<div class="button-super-div">'
				//							+'<button type="button" class="mui-btn cell-btn">章节练习'
				//							+'</button>'
				//
				//
				//						+'</div>'
				+'</div>' + '</a>' + '</li>';
				strhtml = strhtml + str;
			}
//			Itemarr = data;
			if (page == 1) {
				$('#list_id').html(strhtml);
			} else {
				$('#list_id').append(strhtml);
			}
			setupTapCellClick();
		}

		function setupTapCellClick() {
			$('.one_cell').unbind('click');
			$('.one_cell').click(function() {
				var where_type = $(this).attr('where_type');
				var id = $(this).attr('id');
				var hdresourceType = '';
				var coursetype = $(this).attr('coursetype');
				var cdetailtitle = $(this).attr('cdetailtitle');
				var bewrite = $(this).attr('bewrite');
				var imgurl = $(this).attr('img');
				if (where_type != 1) {
					hdresourceType = 0;
					//					alert('互动资源');//
					//					SendBehaviorTrajectoriesNotifi_Authentication('1', '技能课程列表页', '129', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title,message);
					api.openWin({useWKWebView:true,
						name : 'Interactive_Chapter_Window',
						url : '../AuthenticationCousre/Interactive_Chapter_Window.html',
						pageParam : {
							hdresourceType : hdresourceType,
							id : id,
							type : 2,
							openType : 'skillCourse',
							cdetailtitle : cdetailtitle,
							bewrite : bewrite,
							sourceurl : window.location.pathname,
							sourcetitle : document.title,
							quarter_name : api.pageParam.quarter_name
						}
					});
				} else {
					hdresourceType = 1;
					if (coursetype == 2108) {
						//打开自由课程列表
						//						SendBehaviorTrajectoriesNotifi_Authentication('1', '技能课程列表页', '129', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title,message);
						api.openWin({useWKWebView:true,
							name : 'Student_FreeCourseChapterListNew',
							url : '../AuthenticationCousre/FreeCourseChapterList.html',
							pageParam : {
								courseid : id,
								pid : 0,
								cdetailtitle : cdetailtitle,
								bewrite : bewrite,
								openType : 'skillCourse',
								sourceurl : window.location.pathname,
								sourcetitle : document.title,
								quarter_id : api.pageParam.id,
								quarter_name : api.pageParam.quarter_name
							}
						});
					} else if (coursetype == 2109) {
						//						SendBehaviorTrajectoriesNotifi_Authentication('1', '技能课程列表页', '129', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title,message);
						api.openWin({useWKWebView:true,
							name : 'Teacher_StudyCourseInfo',
							url : '../Teacher_Teach/Teacher_StudyCourseInfo.html',
							bgColor : '#fff',
							vScrollBarEnabled : false,
							hScrollBarEnabled : false,
							pageParam : {
								openType : 'skillCourse',
								imgurl : imgurl,
								title : cdetailtitle,
								courseType : 1,
								planid : '',
								courseid : id,
								selected : 1,
								part : '',
								examid : '',
								coursename : cdetailtitle,
								userType : 'student',
								coverimages : imgurl,
								isxueba : 0,
								sourceurl : window.location.pathname,
								sourcetitle : document.title,
								quarter_name : api.pageParam.quarter_name
							}
						});
					} else if (coursetype == 2103) {
						//						SendBehaviorTrajectoriesNotifi_Authentication('1', '技能课程列表页', '129', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title,message);
						//打开视频课程
						api.openWin({useWKWebView:true,
							name : 'VideoCourseWindow',
							url : '../AuthenticationCousre/VideoCourseWindow.html',
							pageParam : {
								openType : 'skillCourse',
								courseid : id,
								coursename : cdetailtitle,
								imgurl : imgurl,
								sourceurl : window.location.pathname,
								sourcetitle : document.title,
								quarter_name : api.pageParam.quarter_name
							}
						});
					}
				}
			});
		}

		//开始考试
		function openTest(data, learn_test, enumber) {
			event.stopPropagation();
			if (enumber != null && enumber != '') {
				//				SendBehaviorTrajectoriesNotifi_Authentication('1', '技能课程列表页', '129', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title,message);
				api.openWin({useWKWebView:true,
					name : 'SkillCourseTestExam',
					url : 'SkillCourseTestExam.html',
					pageParam : {
						cid : learn_test,
						learn_num : data.id,
						exam : enumber,
						course_name : data.title,
						quarter_id : api.pageParam.id,
						sourceurl : window.location.pathname,
						sourcetitle : document.title,
						quarter_name : api.pageParam.quarter_name
					},
					slidBackEnabled : false,
					softInputMode : 'pan',
				});
			} else {
				ShowToast('考试已过期');
			}
		}

		//查看成绩
		function openTestScore(data, cjid, learn_test) {
			event.stopPropagation();
			//			SendBehaviorTrajectoriesNotifi_Authentication('1', '技能课程列表页', '129', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title,message);
			api.openWin({useWKWebView:true,
				name : 'SkillCourseTestExamScore',
				url : 'SkillCourseTestExamScore.html',
				pageParam : {
					exam_id : learn_test,
					id : data.id,
					cjid : cjid,
					course_name : data.title,
					quarter_id : api.pageParam.id,
					sourceurl : window.location.pathname,
					sourcetitle : document.title,
					quarter_name : api.pageParam.quarter_name
				},
				slidBackEnabled : false,
				softInputMode : 'pan',
			});
		}

		//查看成绩弹窗，点击确定，隐藏查看成绩弹窗
		function hideScore() {
			$('#ScoreAlert').hide();
		}

		function pushToBaiDuPlayer(is_encr, baidu_cloud_id_url, path, title) {
			var message = "学习职业道德" + "《" + title + "》" + "</br>" + api.pageParam.quarter_name + "认证";
			SendBehaviorTrajectoriesNotifi_Authentication('0', '技能课程列表详情页', '136', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title, message);
			if (path != null && path != '' && path.indexOf("http://") < 0) {
				path = 'http://bos.cfnet.org.cn' + path;
			}
			var videoPath = path;
			if (is_encr == 2) {//转码
				videoPath = baidu_cloud_id_url;
				api.openWin({useWKWebView:true,
					name : 'BaiDuWebVideo',
					url : '../Study/BaiDuWebVideo.html',
					pageParam : {
						title : title,
						url : videoPath,
						token : '',
						vid : '',
						message : message
					},
					slidBackEnabled : false
				});
			} else {
				api.openWin({useWKWebView:true,
					name : 'BaiDuWebVideo',
					url : '../Study/BaiDuWebVideo.html',
					pageParam : {
						title : title,
						url : videoPath,
						token : '',
						vid : '',
						message : message
					},
					slidBackEnabled : false
				});
			}
		}
	</script>
</html>